import { problemInfo } from '@/static/js/problem'
import { completeTask } from '@/static/js/points.js';
export default {
  data() {
    return {
      problemInfo: {},//问题详情
      showPointsTips: false,//任务完成提示
      pointsObj: {},//任务完成对象
    }
  },
  onLoad(e) {
    this.getProblemInfo(e.id)

    this.completeQuest('A1');
  },
  methods: {
    //请求问题详情
    getProblemInfo(id) {
      problemInfo({ id }).then(res => {
        if (res.code == 1) {
          this.problemInfo = res.data;
          this.sourceList = res.data.all_based_source;
        }
      });
    },

    //去依据
    goSource(e) {
      // type 1:税收 2:会计
      if (e.type == 1) {
        uni.navigateTo({ url: `/law/tax/det/index?id=${e.id}` })
      } else {
        uni.navigateTo({ url: `/law/acct/det/index?id=${e.id}` })
      }
    },

    //完成任务
    completeQuest(code) {
      completeTask({ code }).then(res => {
        if (res.code == 1) {
          setTimeout(() => {
            this.showPointsTips = true;
          }, 1000);
          this.pointsObj = res.data;
        }
      })
      setTimeout(() => {
        this.showPointsTips = false;
      }, 3000);
    },
  },
}